<?php
declare (strict_types = 1);

namespace app\common\model;

use think\Model;
use think\model\concern\SoftDelete;
class PurchaseGoodsOuts extends Model
{
    use SoftDelete;
     protected $deleteTime = false;
    // 获取列表
    public static function getList()
    {
        $where = [];
        $limit = input('get.limit');
        
               //按申请部门查找
               if ($apply_depart = input("apply_depart")) {
                   $where[] = ["apply_depart", "like", "%" . $apply_depart . "%"];
               }
               //按类别查找
               if ($category = input("category")) {
                   $where[] = ["category", "like", "%" . $category . "%"];
               }
               //按领取人查找
               if ($receive_user = input("receive_user")) {
                   $where[] = ["receive_user", "like", "%" . $receive_user . "%"];
               }
               //按备注查找
               if ($remarks = input("remarks")) {
                   $where[] = ["remarks", "like", "%" . $remarks . "%"];
               }
        $list = self::order('id','desc')->where($where)->with('getGoodsIn')->paginate($limit);
        return ['code'=>0,'data'=>$list->items(),'extend'=>['count' => $list->total(), 'limit' => $limit]];
    }

    public function getGoodsIn()
    {
        return $this->hasOne(PurchaseGoodsIn::class, 'id', 'goods_in_id');
    }
}
